DEFINITION MODULE Streams;
(*
*    Copyright (c) 1985,1986,1987,1988,1989 by
*    ana-systems, Foster City, California.
*    All Rights Reserved.
*
*    This software is furnished under a license and may be used and copied
*    only  in accordance with  the  terms  of  such  license and  with the
*    inclusion of the above copyright notice.  This software or  any other
*    copies thereof may not be provided or otherwise made available to any
*    other  person.   No title to and ownership of the  software is  herby
*    transferred.
*
*    The information in this software is  subject to change without notice
*    and  should  not be construed as a commitment by ana-systems.   No
*    warranty is implied or expressed.
*   SCCID  = "1.1    1/26/86"; 
*)
  FROM SYSTEM IMPORT 
        WORD, ADR;
  FROM Files IMPORT 
         File, FileState;


  EXPORT QUALIFIED
        Connect,  Disconnect,  ResetStream,   WriteWord,  WriteChar,
        EndWrite, ReadWord,    ReadChar,       EOS,       STREAM;

  TYPE
      StreamType  = RECORD
                 f  : File;
                 isWordStream : BOOLEAN;
               END;
      STREAM = POINTER TO StreamType;

  PROCEDURE Connect(VAR s : STREAM; 
                        f : File;
                        ws: BOOLEAN);
        (* ws = TRUE : word stream;
           ws = FALSE: text stream; *)

  PROCEDURE Disconnect(VAR s     : STREAM; 
                        closefile: BOOLEAN);
        (* disconnect STREAM s from the file connected by routine Connect.
           closefile = TRUE  then the disconnected file will be closed.
           closefile = FALSE then the disconnected file is still open. *)

  PROCEDURE ResetStream(s: STREAM);
        (* reset s *)

  PROCEDURE WriteWord(s: STREAM; w: WORD);

  PROCEDURE WriteChar(s: STREAM; ch: CHAR);

  PROCEDURE EndWrite(s: STREAM);
        (* finish writing the stream *)

  PROCEDURE ReadWord(s: STREAM; VAR w: WORD);

  PROCEDURE ReadChar(s: STREAM; VAR ch: CHAR);
         
  PROCEDURE EOS(s: STREAM): BOOLEAN;
        (* check End_of_STREAM *)
END Streams.
